home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / QOOXX5 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.5 KB  |  77 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.AbstractButton;
  4. import com.sun.java.swing.ButtonModel;
  5. import com.sun.java.swing.Icon;
  6. import com.sun.java.swing.JMenu;
  7. import com.sun.java.swing.JMenuItem;
  8. import com.sun.java.swing.plaf.UIResource;
  9. import java.awt.Component;
  10. import java.awt.Graphics;
  11. import java.io.Serializable;
  12.  
  13. class MetalIconFactory$CheckBoxMenuItemIcon implements Icon, UIResource, Serializable {
  14.    public void paintIcon(Component c, Graphics g, int x, int y) {
  15.       JMenuItem b = (JMenuItem)c;
  16.       ButtonModel model = ((AbstractButton)b).getModel();
  17.       boolean isSelected = model.isSelected();
  18.       boolean isEnabled = model.isEnabled();
  19.       boolean isPressed = model.isPressed();
  20.       boolean isArmed = model.isArmed();
  21.       g.translate(x + 4, y);
  22.       if (isEnabled) {
  23.          if (!isPressed && !isArmed) {
  24.             g.setColor(MetalLookAndFeel.getControlDarkShadow());
  25.             g.drawLine(0, 0, 8, 0);
  26.             g.drawLine(0, 0, 0, 8);
  27.             g.drawLine(8, 2, 8, 8);
  28.             g.drawLine(2, 8, 8, 8);
  29.             g.setColor(MetalLookAndFeel.getControlHighlight());
  30.             g.drawLine(1, 1, 7, 1);
  31.             g.drawLine(1, 1, 1, 7);
  32.             g.drawLine(9, 1, 9, 9);
  33.             g.drawLine(1, 9, 9, 9);
  34.          } else {
  35.             g.setColor(MetalLookAndFeel.getControlInfo());
  36.             g.drawLine(0, 0, 8, 0);
  37.             g.drawLine(0, 0, 0, 8);
  38.             g.drawLine(8, 2, 8, 8);
  39.             g.drawLine(2, 8, 8, 8);
  40.             g.setColor(MetalLookAndFeel.getPrimaryControl());
  41.             g.drawLine(1, 1, 7, 1);
  42.             g.drawLine(1, 1, 1, 7);
  43.             g.drawLine(9, 1, 9, 9);
  44.             g.drawLine(1, 9, 9, 9);
  45.          }
  46.       } else {
  47.          g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
  48.          g.drawRect(0, 0, 8, 8);
  49.       }
  50.  
  51.       if (isSelected) {
  52.          if (!isEnabled) {
  53.             g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
  54.          } else if (!model.isArmed() && (!(c instanceof JMenu) || !model.isSelected())) {
  55.             g.setColor(((Component)b).getForeground());
  56.          } else {
  57.             g.setColor(MetalLookAndFeel.getMenuSelectedForeground());
  58.          }
  59.  
  60.          g.drawLine(2, 2, 2, 6);
  61.          g.drawLine(3, 2, 3, 6);
  62.          g.drawLine(4, 4, 8, 0);
  63.          g.drawLine(4, 5, 9, 0);
  64.       }
  65.  
  66.       g.translate(-(x + 4), -y);
  67.    }
  68.  
  69.    public int getIconWidth() {
  70.       return MetalIconFactory.access$menuCheckIconSize().width;
  71.    }
  72.  
  73.    public int getIconHeight() {
  74.       return MetalIconFactory.access$menuCheckIconSize().height;
  75.    }
  76. }
  77.